home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-09-28 | 6.5 KB | 206 lines |
- '***************************
- '* AMOS Professional *
- '* *
- '* FADE *
- '* *
- '* (c) Europress Software *
- '* *
- '* Ronnie Simpson *
- '***************************
- '
- '-------------------------------------------
- 'SETTING UP
- '-------------------------------------------
- 'Standard form of Fade. (fade all colours in a palette to black)
- '
- ' +----->The command (Smoothly blend all colours to black)
- ' | +----->The speed (in vertical blanks) of each colour change
- ' | | +----->Wait until all colours have changed
- ' | | | +----->The number of vertical blank periods required
- ' | | | |
- ' ^ ^ ^ ^
- ' Fade 5 : Wait 60
- '
- 'The standard form of this command takes each colour index in a palette and
- 'reduces its value by 1 until it reaches 0 (black)
- 'eg. if colour 1 was initially $585 then the sequence would be-
- ' $585 - $474 - $363 - $252 - $141 - $030 - $020 - $010 - $000
- '
- 'The speed of the fade is counted in vertical blank periods (50 per second)
- 'ie. Fade 1 is the fastest and Fade 25 would be slow, with each colour change
- 'taking half a second.
- '
- 'The wait command is used to halt program operation until the fade is
- 'complete and can be calculated as follows:-
- ' Wait time=fade speed * 15
- '
- 'eg. Fade 1 : Wait 15 Fade 2 : Wait 30 Fade 10 : Wait 150
- '
- '-------------------------------------------
- 'EXTENDED FORMS OF FADE
- '-------------------------------------------
- 'Fade to a new palette
- '
- 'eg. Fade 2,$222,$444,$666,$888,$AAA : Wait 30
- '
- 'This form of fade would slowly alter the palette to the new colour values
- 'used in the instruction.
- 'Any number of colours can be altered up to the maximum for the screen mode
- 'and any that are left out will be totally unnafected by the fade.
- 'For example to alter only colours 0,1,2,5 and 7 you would use:-
- '
- ' Fade 5,$0,$F0,$F00,,,$639,,$936 : Wait 60
- '
- '-------------------------------------------
- 'Fade to a palette taken from another screen
- '
- ' Fade speed to screen number
- '
- 'eg. Fade 5 To 1 (Fade speed 5 to colours of palette at screen 1)
- ' Fade 1 To 2 (Fade speed 1 to colours of palette at screen 2)
- '
- '---------------------------
- 'Fade to the sprite palette
- '
- ' Fade speed to -1 (use any negative number)
- '
- 'eg. Fade 5 To -1 (Fade speed 5 to colours of Sprite palette)
- '
- 'When a fade to screen or sprite palette is made, an optional 16 bit mask
- 'may be used to load just part of the palette
- '
- ' Fade speed to screen number , mask
- '
- 'eg. Fade 5 To 1,%1010101010101010 (fade every second colour)
- ' Fade 5 To 1,%1110 (fade colours 1,2,3 and ingnore colour 0)
- '
- 'Each colour is represented by 1 bit of the mask, if a bit is set to 1
- 'then that colour will be changed.
- '-------------------------------------------
- 'WORKING EXAMPLE
- '--------------------------------------------------------------
- 'The following program opens 2 screens, plots some graphics and
- 'demonstrates the various uses of the fade instruction.
- '--------------------------------------------------------------
- Rem *** Open and tidy the screens
- '
- Screen Open 1,640,200,16,Hires
- Screen Open 0,640,200,16,Hires
- Screen To Front 0 : Screen 0
- Flash Off : Cls 0 : Hide
- Ink 8,0 : Text 270,199,"PLEASE WAIT......"
- '
- '
- Rem *** Call a procedure to draw the graphics
- '
- INIT_SCREEN
- Ink 8,0 : Text 195,199,"PRESS AND HOLD ANY MOUSE KEY TO QUIT"
- '
- '
- Rem *** start the main loop
- '
- Do
- '
- '
- Rem *** Select the type of fade
- '
- TYPE=Rnd(5)
- '
- '---------------------------------------------------------
- Rem *** If TYPE=1 then fade a palette to the hidden screen
- '
- If TYPE=1
- R=Rnd(2)+1
- Screen 1
- SPEED=1 : Gosub(R) : Wait 15
- Exit If Mouse Key
- Screen 0
- '
- '
- Rem *** now perform a Fade to screen with mask
- Fade 5 To 1,%101010101010101 : Wait 45
- Exit If Mouse Key
- End If
- '---------------------------------------------------------
- '
- Rem *** Select a random fade type (R) and a random speed
- '
- R=Rnd(12)+1
- SPEED=Rnd(10)+1
- '
- '
- Rem *** Using a subroutine perform the fade
- '
- Gosub(R) : Wait SPEED*15
- Exit If Mouse Key
- '
- '
- Rem *** Go back and do it all again
- Loop
- '
- '
- Edit
- '
- '
- Rem *** The subroutines
- '
- 1 Fade SPEED,0,$1,$2,$3,$4,$5,$6,$7,$8,$9,$A,$B,$C,$D,$E,$F : Return
- 2 Fade SPEED,0,$10,$20,$30,$40,$50,$60,$70,$80,$90,$A0,$B0,$C0,$D0,$E0,$F0 : Return
- 3 Fade SPEED,0,$100,$200,$300,$400,$500,$600,$700,$800,$900,$A00,$B00,$C00,$D00,$E00,$F00 : Return
- 4 Fade SPEED,0,$101,$202,$303,$404,$505,$606,$707,$808,$909,$A0A,$B0B,$C0C,$D0D,$E0E,$F0F : Return
- 5 Fade SPEED,0,$11,$22,$33,$44,$55,$66,$77,$88,$99,$AA,$BB,$CC,$DD,$EE,$FF : Return
- 6 Fade SPEED,0,$110,$220,$330,$440,$550,$660,$770,$880,$990,$AA0,$BB0,$CC0,$DD0,$EE0,$FF0 : Return
- 7 Fade SPEED,0,$111,$222,$333,$444,$555,$666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF : Return
- 8 Fade SPEED,0,$F00,$E00,$D00,$C00,$B00,$A00,$901,$802,$703,$604,$505,$406,$307,$208,$109 : Return
- 9 Fade SPEED,0,$F0,$E0,$D0,$C0,$B0,$A0,$91,$82,$73,$64,$55,$46,$37,$28,$19 : Return
- 10 Fade SPEED : Return
- 11 Fade SPEED,0,,0,,0,,0,,0,,0,,0,,0 : Return
- 12 Fade SPEED,,0,,0,,0,,0,,0,,0,,0,,0 : Return
- 13 Fade SPEED,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF,$FFF : Return
- '
- '
- Rem *** The draw graphics procedure
- Procedure INIT_SCREEN
- Palette 0,$111,$222,$333,$444,$555,$666,$777,$888,$999,$AAA,$BBB,$CCC,$DDD,$EEE,$FFF
- For X=0 To 14
- Ink X+1
- Draw X,0 To X,104
- Draw 29-X,0 To 29-X,104
- Draw X+30,0 To X+30,104
- Draw 59-X,0 To 59-X,104
- Draw X+60,0 To X+60,104
- Draw 89-X,0 To 89-X,104
- Draw X+90,0 To X+90,104
- Draw 119-X,0 To 119-X,104
- Draw X+120,0 To X+120,104
- Draw 149-X,0 To 149-X,104
- Next
- For Y=0 To 14
- Ink Y+1
- Draw 170,Y To 319,Y
- Draw 170,29-Y To 319,29-Y
- Draw 170,Y+30 To 319,Y+30
- Draw 170,59-Y To 319,59-Y
- Draw 170,Y+60 To 319,Y+60
- Draw 170,89-Y To 319,89-Y
- Draw 170,Y+90 To 319,Y+90
- Next
- For X=0 To 90
- Add C,1,1 To 15 : Ink C
- Box 100-X,153-X/2 To 100+X,153+X/2
- Next
- For X=1 To 45
- Add C,1,1 To 15 : Ink C
- Circle 540,153,X
- Next
- For X=4 To 120
- Add C,1,1 To 15 : Ink C
- Ellipse 320,153,X,X/4
- Next
- Clip 350,0 To 630,104
- For X=350 To 740
- Add C,1,1 To 15 : Ink C
- Draw X,0 To X-X,0+X
- Next
- Clip
- End Proc